<?php
/**
 * this is cloud search http request class test file
 *
 *
 */
require_once 'index.php';
require_once 'Framework/TestCase.php';
class NicedTest extends PHPUnit_Framework_TestCase 
{
    const URI = "/sample/index";
    const CHECK_STRING = "mytesting";
    /**
     * test case, function name begin with  test, e.g.testSum
     * or use @test for not begin with test.
     *
     */
    public function testMVCByCmd()
    {
        $cmd = "php -f ".DIR_PUBLIC."index.php '".self::URI."'";
        $fh = popen($cmd, "r");
        $rt = trim(fread($fh, 1024));

        if (strlen($rt) == 0) 
        {
            throw new Exception("execute os cmd ".$cmd.", os return is ".$rt);
        } 
        pclose($fh);

        $this->assertTrue((bool)strpos($rt, self::CHECK_STRING));
    }

    public function __testMVCByCurl()
    {
        $url = SC::get("board_config.main_domain").self::URI;      
        $rt  = Util::curl($url);
        $str = $rt["result"];
        $this->assertTrue((bool)strpos($str, self::CHECK_STRING));
    }


    /**
     * execute before class
     *
     */
    public static function setUpBeforeClass()
    {

    }

    /**
     * execute before case
     *
     */
    protected function setUp()
    {

    }

    /**
     *
     * execute before assert
     */
    protected function assertPreConditions()
    {

    }

    /**
     *
     * execute after assert
     */
    protected function assertPostConditions()
    {

    }

    /**
     * execute after case
     */
    protected function tearDown()
    {

    }

    /**
     * execute after class
     *
     */
    public static function tearDownAfterClass()
    {

    }


}//end class
